import { executeSql } from "../util/db.js";

export const selectCommentsNew = function () {
    let sql = "select author,`date`,content from comments order by `date` desc limit 0,6;";
    return executeSql(sql);
}

export const insertcomments = function (author, content, articleId) {
    let sql = "insert into comments values (null,?,?,curdate(),curtime(),'待审核',? );";
    return executeSql(sql, [author, content, articleId]);
}

export const selectCommentsAll = function (id) {
    let sql = 'select author , date , content from comments where articleId=?;';
    return executeSql(sql, [id]);
}

export const deleteComment = function (id){
  let sql = 'delete from comments where id=?;';
  return executeSql(sql,[id]);
};

export const updateCommentReject = function (id) {
    let sql = 'update comments set state="已拒绝" where id=?;';
    return executeSql(sql, [id]);
}

export const updateCommentPass = function (id) {
    let sql = 'update comments set state="已通过" where id=?;';
    return executeSql(sql, [id]);
}

